﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Collections;
using log4net;
using WEB.DAL.DBManagers;
using WEB.BLL.Entities;
using WEB.Exceptions;

namespace WEB.BLL.Services
{
    #region IModuleService

    /// <summary>
    /// ModuleService object for Ibatis mapped table 'Module'.
    /// </summary>
    public class IModuleService : BaseSqlMapDao
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(IModuleService).Name);
        public IList<ModuleEntity> LoadAll()
        {
            try
            {
                return ExecuteQueryForList< ModuleEntity>("ModuleLoadAll", null);
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        public ModuleEntity LoadByPrimaryKey(ModuleEntity objE)
        {
            try
            {
                return ExecuteQueryForObject< ModuleEntity>("ModuleLoadByPrimaryKey", objE);
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        /// <summary>
        /// add new Module to DB 
        /// </summary>
        /// <param name="objE"></param>
        /// <returns></returns>
        public int Insert(ModuleEntity objE)
        {
            try
            {
                ExecuteInsert("ModuleInsert", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        /// <summary>
        /// update Module to DB 
        /// </summary>
        /// <param name="objE"></param>
        /// <returns></returns>
        public int Update(ModuleEntity objE)
        {
            try
            {
                ExecuteUpdate("ModuleUpdate", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        /// <summary>
        /// delete Module to DB 
        /// </summary>
        /// <param name="objE"></param>
        /// <returns></returns>
        public int Delete(ModuleEntity objE)
        {
            try
            {
                ExecuteDelete("ModuleDelete", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
    }
    #endregion
}
